package com.qidian.mespro.controller;

import com.github.pagehelper.PageInfo;
import com.qidian.mespro.service.WorkflowProductService;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.WorkflowProcess;
import com.qidianit.mes.pojo.WorkflowProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ author: 周晓轩
 * @ company 起点编程
 * @ time: 2025/9/19 - 18:27
 * @ Description:
 */
@RestController
@RequestMapping("/workflowProduct")
public class WorkflowProductController {

    @Autowired
    private WorkflowProductService workflowProductService;

    @GetMapping("/page")
    public Result<PageInfo<WorkflowProduct>> getList(Long workflowId, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int pageSize) {
        return workflowProductService.selectByWorkflowId(workflowId, pageNum, pageSize);
    }

    @PostMapping("/add")
    public Result<WorkflowProduct> save(@RequestBody WorkflowProduct workflowProduct){
        return workflowProductService.addWorkflowProduct(workflowProduct);
    };

    @GetMapping("/{id}")
    public Result<WorkflowProduct> getByID(@PathVariable("id") Long id){
        return workflowProductService.selectWorkflowProductById(id);
    }

    @PutMapping("/update")
    public Result update(@RequestBody WorkflowProduct workflowProduct){
        return workflowProductService.updateWorkflowProduct(workflowProduct);
    };

    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable Long id){
        return workflowProductService.deleteWorkflowProductById(id);
    }

    @DeleteMapping("/batchDelete")
    public Result batchDelete(Long [] id){
        return workflowProductService.batchDelete(id);
    };
}
